<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
  <head>
    <title>Test Index2</title>
    <%= stylesheet_link_tag "../javascripts/ext/resources/css/ext-all.css" %>
    <%= javascript_include_tag "ext/adapter/prototype/prototype.js" %>
    <%= javascript_include_tag "ext/adapter/prototype/scriptaculous.js" %>
    <%= javascript_include_tag "ext/adapter/prototype/effects.js" %>
    <%= javascript_include_tag "ext/adapter/prototype/ext-prototype-adapter.js" %>
    <%= javascript_include_tag "ext/ext-all-debug.js" %>
    <%= javascript_include_tag "ext/build/locale/ext-lang-zh_CN.js" %>
    <style>
      .hide-label label {
        display:none;
      }
      .show-label label {
      }
    </style>
  </head>
  <body>
    <script>
        Ext.override(Ext.form.Field, {
            hideItem :function(){
                this.formItem.addClass('x-hide-' + this.hideMode);             
            },

            showItem: function(){
                this.formItem.removeClass('x-hide-' + this.hideMode);             
            },
            setFieldLabel: function(text) {
                var ct = this.el.findParent('div.x-form-item', 3, true);
                var label = ct.first('label.x-form-item-label');
                label.update(text);
            }
        });
        Ext.onReady(function(){
            var link_label = new Ext.form.Label({
                fieldLabel: '联系人',
                //hideLabel: true,
                name: 'link_man_label',
                allowBlank: true,
                blankText: "联系人不允许为空",
                anchor: '90%',
                text: '我烤:'
            });
            //link_label.hide();
            //link_label.show();
            var link_man = new Ext.form.TextField({
                fieldLabel: '联系人',
                hideLabel: true,
                name: 'link_man',
                allowBlank: true,
                blankText: "联系人不允许为空",
                anchor: '90%',
                value: ''
            });
            /*link_man.setVisible(false);
            link_man.disable();// for validation  
            link_man.hide();  */
            //link_man.hide();
            //link_man.show();
            
            //alert(link_man.getEl());
            var simple = new Ext.FormPanel({
                labelWidth: 75, // label settings here cascade unless overridden
                url:'save-form.php',
                frame:true,
                title: 'Simple Form',
                bodyStyle:'padding:5px 5px 0',
                width: 350,
                defaults: {width: 230},
                items: [{
                        layout: 'column',
                        border: false,
                        id:'test',
                        items: [{
                                columnWidth: .5,
                                layout: 'form',
                                border: false,
                                items: [link_label]
                            }, {
                                columnWidth: .5,
                                layout: 'form',
                                border: false,
                                items: [link_man]
                            }]
                    },{
                        fieldLabel: 'Last Name',
                        xType: 'textfield',
                        name: 'last'
                    },{
                        fieldLabel: 'Company',
                        xType: 'textfield',
                        name: 'company'
                    }, {
                        fieldLabel: 'Email',                        
                        name: 'email',
                        vtype:'email'
                    }, new Ext.form.TimeField({
                        fieldLabel: 'Time',
                        name: 'time',
                        minValue: '8:00am',
                        maxValue: '6:00pm'
                    })
                ],
    
                buttons: [{
                        text: 'Save'
                    },{
                        text: 'Cancel'
                    }]
            });
            //link_man.hide();
            //link_label.hide();
            //simple.remove(link_man);
            //simple.add(link_man);
            Ext.getCmp('test').hide();
            Ext.getCmp('test').show();
            simple.render(document.body);
        });
    </script>
  </body>
</html>